#include<typeinfo>
#include<iostream>
#include"compractice.hpp"

lex tokenReader;
parser treeBuilder;
interpreter executor;

// class A{
// public:
// 	virtual void f(){std::cout<<"A\n";}
// };
// class B:public A{
// public:
// 	void f(){std::cout<<"B\n";}
// };

int main(int argc,char** args){
	if(argc==1){
		std::cout<<"Usage: test <filepath>\n";
		return 0;
	}
	FILE* f=fopen(args[1],"r");
	tokenReader.scan(f);
	if(tokenReader.error()){
		std::cout<<"compile failed!\n";
		return 0;
	}
	// tokenReader.output();
	treeBuilder.setTokens(tokenReader.getList());
	executor.setTokens(tokenReader.getList());
	executor.initStatement(&treeBuilder);
	if(treeBuilder.error()){
		std::cout<<"compile failed!\n";
		return 0;
	}
	executor.setGlobalEnvironment();
	executor.run();
	return 0;
}